//引入模块
const http = require("http");
const querystring = require("querystring");

http.createServer(function (request, response) {
    let _param = "";
    if (request.url !== "/favicon.ico") {
        //请求有数据流
        request.on("data", function (_data) {
            _param += _data;
        });
        //请求数据流读取完毕后
        request.on("end", function () {
            let parsedUrlQuery = querystring.parse(_param);
            response.writeHead(200, {"Content-Type": "text/html;charset=UTF-8"});
            response.write("用户名：" + parsedUrlQuery.username);
            response.write("</br>");
            response.write("密码：" + parsedUrlQuery.password);
            response.end(); //不加此行浏览器会一直加载
        });
    }

}).listen(8080); //监听的端口

console.log("nodejs 8080 port is starting...");